<template>
  <div>
    <el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" title="车辆预订"   :visible.sync="dialogVisible">
      <el-row :gutter="15">
        <!--门店与车辆信息-->
        门店：{{storeInfo.storeName}}
        车辆:{{carInfo.carName}}
        <el-form ref="orderForm" :model="orderData" size="medium" label-width="100px">
          <el-col :span="23">
            <el-form-item label="租期范围" prop="orderTime">
              <el-date-picker type=datetimerange" v-model="orderData.orderTime" format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss" :style="{width: '100%'}" start-placeholder="开始日期"
                end-placeholder="结束日期" range-separator="至" clearable></el-date-picker>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div slot="footer">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="handleConfirm">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {addOrder} from "@/api/oms/order";
export default {
  inheritAttrs: false,
  props: [storeInfo,carInfo],
  data() {
    return {
      name:"orderForm",
      dialogVisible: false,
      orderData: {
        carId: 0,
        carName: "",
        discount: 0,
        driveDays: "",
        driveEndDate: "",
        driveHours: "",
        driveStartDate: "",
        isDeleted: true,
        orderId: 0,
        orderNumber: "",
        payAmount: 0,
        payType: "",
        storeName: "",
        totalAmount: 0,
        userId: 0,
        orderTime: null,
      }
    }
  },
  computed: {},
  watch: {},
  created() {

  },
  mounted() {},
  methods: {
    onOpen() {},
    onClose() {
      this.$refs['orderForm'].resetFields()
    },
    close() {
      this.$emit('update:visible', false)
    },
    handleConfirm() {
      this.$refs['orderForm'].validate(valid => {
        if (!valid) return

        //下单
        addOrder(this.orderData).then(response=>{
          this.$message.success("预定成功！")
        })

        this.close()
      })
    },
  }
}

</script>
<style>
</style>
